package com.appistry.management;

import java.io.InputStream;
import java.net.InetAddress;
import java.util.List;
import java.util.Map;

import com.appistry.management.exception.FabricManagerException;

public interface Fabric extends Controller, Stateable {

	/**
	 * Kills this instance
	 * 
	 * @throws FabricManagerException
	 */
	public void kill() throws FabricManagerException;

	/**
	 * Gets a more detailed information about this fabric than getFabricInfo().
	 * Includes name, description, version, address, etc.
	 * 
	 * @return
	 * @throws FabricManagerException
	 */
	public FabricOverview getFabricOverview() throws FabricManagerException;

	/**
	 * Gets the name and description of this fabric
	 * 
	 * @return
	 * @throws FabricManagerException
	 */
	public FabricInfo getFabricInfo() throws FabricManagerException;

	/**
	 * Updates the fabric name and description
	 * 
	 * @param fabricInformation
	 * @throws FabricManagerException
	 */
	public void putFabricInfo(FabricInfo fabricInformation) throws FabricManagerException;

	/**
	 * Gets performance information of this fabric.
	 * 
	 * @return map of each machine and its performance info
	 * @throws FabricManagerException
	 */
	public Map<InetAddress, WorkerPerformanceInfo> getFabricPerformanceInfo() throws FabricManagerException;

	/**
	 * Gets a Manifest of active/staged files
	 * 
	 * @return
	 * @throws FabricManagerException
	 */
	public Manifest getManifest() throws FabricManagerException;

	/**
	 * Gets a list of files in the Manifest
	 * 
	 * @return
	 * @throws FabricManagerException
	 */
	public List<ManifestEntry> getManifestEntryList() throws FabricManagerException;

	/**
	 * Gets a specific ManifestEntry
	 * 
	 * @param entry
	 * @return
	 * @throws FabricManagerException
	 */
	public ManifestEntry getManifestEntry(String entry) throws FabricManagerException;

	// Shutdown List
	public ShutdownList getShutdownList() throws FabricManagerException;

	public void deleteShutdownList() throws FabricManagerException;

	/**
	 * Gets a list of ConsoleExtensions
	 * @return
	 * @throws FabricManagerException
	 */
	public List<ConsoleExtension> getConsoleExtensions() throws FabricManagerException;

	/**
	 * Gets a list of files managed by this fabric
	 * 
	 * @return
	 * @throws FabricManagerException
	 */
	public List<FabricFile> getFileList() throws FabricManagerException;

	/**
	 * Gets a specific file
	 * 
	 * @param fileName
	 * @return
	 * @throws FabricManagerException
	 */
	public InputStream getFile(String fileName) throws FabricManagerException;

	/**
	 * Deletes a specific file
	 * 
	 * @param fileName
	 * @return
	 * @throws FabricManagerException
	 */
	public boolean deleteFile(String fileName) throws FabricManagerException;

	/**
	 * Puts a file to this fabric
	 * 
	 * @param fileName
	 * @param content
	 * @throws FabricManagerException
	 */
	public void putFile(String fileName, InputStream content) throws FabricManagerException;

	/**
	 * Gets a list of workers that are in this fabric
	 * 
	 * @return
	 * @throws FabricManagerException
	 */
	public List<Worker> getWorkers() throws FabricManagerException;

	/**
	 * Gets a list of applications managed by this fabric
	 * 
	 * @param showDeleted
	 * @return
	 * @throws FabricManagerException
	 */
	public List<Application> getApplications(boolean showDeleted) throws FabricManagerException;

	/**
	 * Gets a list of fabric archives managed by this fabric
	 * 
	 * @param showDeleted
	 * @return
	 * @throws FabricManagerException
	 */
	public List<FabricArchive> getFabricArchives(boolean showDeleted) throws FabricManagerException;

	/**
	 * Gets a list of services managed by this fabric
	 * 
	 * @return
	 * @throws FabricManagerException
	 */
	public List<Service> getServices() throws FabricManagerException;
}
